package cn.lyf.condition;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class IsLinux implements Condition {
    ConfigurableListableBeanFactory factory;
    Environment env;
    BeanDefinitionRegistry registry;

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        factory = context.getBeanFactory();
        registry = context.getRegistry();
        env = context.getEnvironment();
        //registry.containsBeanDefinition(beanName)
        return env.getProperty("os.name").contains("linux");
    }

}
